﻿using DataAnnotationsExample.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DataAnnotations.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public void CadastrarContato(Contato contato)
        {
            if( ModelState.IsValid )
            {
                //Contato válido
            }
        }

        public ActionResult ConsultaEmailsCadastrados(string Email)
        {
            bool emailDisponivel;

            List<string> listaEmails = new List<string>();
            listaEmails.Add("jose@empresaxpto.com");

            if (listaEmails.Contains(Email))
                emailDisponivel = false;
            else
                emailDisponivel = true;

            return Json(emailDisponivel, JsonRequestBehavior.AllowGet);
        }

    }
}